package dobest.ray.com.jiongjiong.activity.login;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import dobest.ray.com.jiongjiong.R;
import dobest.ray.com.jiongjiong.activity.BaseActivity;
import dobest.ray.com.jiongjiong.activity.MainActivity;
import dobest.ray.com.jiongjiong.activity.login.dataInport.ImportChildDataAcitivty;
import dobest.ray.com.jiongjiong.bean.PresenterData;
import dobest.ray.com.jiongjiong.callback.PresenterCallBack;

/**
 * Created by Administrator on 2016/2/20.
 */
public class LoginActivity extends BaseActivity<LoginPresenter> implements View.OnClickListener, PresenterCallBack {
    private Button btn_login;
    private Button btn_reg;
    private TextView tv_forget;
    private LoginPresenter presenter;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        findViews();
        init();
        addListeners();
    }

    @Override
    public void findViews() {

        btn_login = (Button) findViewById(R.id.btn_login);
        btn_reg = (Button) findViewById(R.id.btn_reg);
        tv_forget = (TextView) findViewById(R.id.tv_forget);
    }

    @Override
    public void init() {
        presenter = new LoginPresenter(this);
        setPresenter(presenter, this);
    }

    @Override
    public void addListeners() {
        btn_login.setOnClickListener(this);
        btn_reg.setOnClickListener(this);
        tv_forget.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        Intent it = null;
        switch (v.getId()) {
            case R.id.btn_login:
                getPresenter().doLogin(this, "15971470520", "111111");
//                it = new Intent(this, MuMingLeShiActivityWelcomeActivity.class);
                it = new Intent(this, MainActivity.class);
                it = new Intent(this, ImportChildDataAcitivty.class);
                startActivity(it);
                finish();
                return;
            case R.id.btn_reg:
                it = new Intent(this, RegisterActivity.class);
                break;
            case R.id.tv_forget:
                it = new Intent(this, ForgetAndGetPasswordActivity.class);
                break;
        }
        if (it != null) {
            startActivity(it);
        }

    }

    @Override
    public <T> void callBackPresenter(PresenterData<T> data) {

    }
}
